package com.zh.media.utils;

import android.annotation.SuppressLint;
import android.content.Context;
import android.net.wifi.WifiManager;
import android.text.format.Formatter;

public class MacAddressUtil {

    @SuppressLint("MissingPermission")
    public static String getMacAddr(Context context) {
        WifiManager wifiMgr = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
        WifiManager.MulticastLock multicastLock = wifiMgr.createMulticastLock("multicastLock");
        multicastLock.acquire();

        String macAddress = "02:00:00:00:00:00";
        try {
            macAddress = wifiMgr.getConnectionInfo().getMacAddress();
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            multicastLock.release();
        }

        return macAddress;
    }

   /* public static String getFormattedMacAddress(Context context) {
        String macAddress = getMacAddr(context);
        return Formatter.f(macAddress);
    }*/
}
